#!/usr/bin/env python

from setuptools import setup
from setuptools import Command
import sys
import os

class ConfluoShell(Command):
    """ Run Confluo shell
    """
    
    description = "Run interactive Confluo shell"
    
    user_options = [('hostname', 'h', 'Server hostname'), 
                    ('port', 'p', 'Server port')]
    
    def initialize_options(self):
        self.hostname = "localhost"
        self.port = "9090"
        
    def finalize_options(self):
        if self.hostname is None:
            raise Exception("Parameter --port is missing")
        if self.port is None:
            raise Exception("Parameter --port is missing")
    
    def run(self):
        python_ex = sys.executable
        os.execv(python_ex, [ python_ex, "-i", "preamble.py"])

setup(name='confluo',
      version='${CONFLUO_VERSION}',
      description='Python Client for Confluo',
      author='Anurag Khandelwal',
      author_email='anuragk@berkley.edu',
      url='https://www.github.com/ucbrise/confluo',
      package_dir={'conflo': 'confluo'},
      packages=['confluo.rpc'],
      setup_requires=['pytest-runner>=2.0,<4.0', 'thrift>=0.10.0'],
      tests_require=['pytest>2.0,<4.0', 'thrift>=${THRIFT_VERSION}'],
      install_requires=['thrift>=0.10.0'],
      cmdclass={'shell' : ConfluoShell}
      )
